<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="<s:url value="/css/style.css"/>" rel="stylesheet"
			type="text/css" />
		<link href="<s:url value="/css/jquery.css"/>" rel="stylesheet"
			type="text/css" />
		<script type="text/javascript" src="<s:url value="/js/jquery.js"/>"></script>
		<script type="text/javascript" src="<s:url value="/js/common.js"/>"></script>
		<script type="text/javascript" src="<s:url value="/js/jquery-ui.js"/>"></script>
		<script type="text/javascript">
	function doSubmit() {
		// here is validate form .
		$('#listForm').submit();
	};
 	function goEdit(){
       var t=$('#listForm');
       t.attr('action',t.attr('action').replace('list','edit'));
       $('#listForm').submit();
	};
 	$( function() {
		$('#selStartDate').datepicker({dateFormat:'yy-mm-dd'});
		$('#selEndDate').datepicker({dateFormat:'yy-mm-dd'});
	});
		   function doSelectPlan(plan,day,ChannelId){
				$('#selPlanId').val(plan);
				$('#selDay').val(day);
				$('#selAdChannelId').val(ChannelId);
				var t=$('#listForm');
                t.attr('action','select');
				$('#listForm').submit();
			};
			function doSelectDay(day,ChannelId){
				$('#selDay').val(day);
				$('#selAdChannelId').val(ChannelId);
				var t=$('#listForm');
                t.attr('action','select');
				$('#listForm').submit();
			};
</script>
	</head>
	<body>
		<s:include value="/common/up.jsp"></s:include>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td class="box">
					<s:form action="list" name="listForm" id="listForm"
						namespace="/marketing">
						<input type="hidden" id="startIndex" name="startIndex" value="0" />
						<s:hidden name="selPlanId" id="selPlanId"/> 
					    <s:hidden name="selDay" id="selDay"/> 
					    <s:hidden id="selAdChannelId" name="selAdChannelId" />
						<table width="100%" border="0" cellpadding="0" cellspacing="0"
							class="searchbg">
							<tr>
								<td>
									Year:
									<s:select id="year" list="{2008,2009,2010,2011}" name="year">
									</s:select>
									Month:
									<s:select id="month" list="{1,2,3,4,5,6,7,8,9,10,11,12}"
										name="month">
									</s:select>
									AdChannel:
									<s:textfield name="adChannelName" id="adChannelName" />
								 	<img src="../img/right/btns.gif" border="0"
										onclick="javascript:doSubmit();" align="absmiddle" />
									<img onclick="javascript:goEdit();"
										src="<s:url value="/img/right/plan.gif"/>" border="0"
										align="absmiddle" />
								</td>
							</tr>
						</table>
					</s:form>
					<table width="100%" border="0" cellpadding="0" cellspacing="1"
						class="box2">
						<tr>
							<th class="tablecolour1" nowrap="nowrap">
								<s:property value="year" />
								年
								<s:property value="month" />
							</th>
							<s:iterator value="days">
								<th class="tablecolour1">
									<s:property />
								</th>
							</s:iterator>
						</tr>
						<tr>
							<s:iterator value="adChannels.items" status="status">
								<tr>
									<td  class="tablecolour1" nowrap="nowrap">
										<s:property value="name" />
										<s:set name="channelId" value="id" />
									</td>
									<s:iterator value="days">
										<s:set name="bday" />
										<s:set name="planid"
												value="getAdChannelPlan(year,month,#bday,#channelId)" />
										<s:if test="#planid>0">
										<td class="tablecolour2" style="cursor:pointer" ondblclick="doSelectPlan(
										<s:property value="#planid" />  ,
										<s:property value="#bday" /> ,
										<s:property value="#channelId" />)">
											√
										</td>
										</s:if>
										<s:else>
										<td class="tablecolour2"  style="cursor:pointer" ondblclick="doSelectDay(<s:property value="#bday" /> ,
										<s:property value="#channelId" />)">
											&nbsp;
										</td>
										</s:else>
										
									</s:iterator>
								</tr>
							</s:iterator>
						</tr>
					</table>
					<s:include value="page.jsp"></s:include>
				</td>
			</tr>
		</table>
		<s:include value="/common/down.jsp"></s:include>
	</body>
</html>